package org.example.Utill;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DatabaseUtil {
    private static final String URL = "jdbc:mysql://localhost:3306/roll?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8";
    private static final String USERNAME = "gongxi";
    private static final String PASSWORD = "gongxi";

    static {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            System.err.println("无法加载 MySQL 驱动。");
        }
    }

    public static Connection getConnection() throws SQLException {
        return DriverManager.getConnection(URL, USERNAME, PASSWORD);
    }
}
